<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">

				<el-form-item>
					<el-date-picker type="date" placeholder="开始时间"  format="yyyy-MM-dd"   v-model="filters.startTime" style="width: 100%;"></el-date-picker>
				</el-form-item>
				<el-form-item>
					<el-date-picker type="date" placeholder="结束时间"  format="yyyy-MM-dd"   v-model="filters.endTime" style="width: 100%;"></el-date-picker>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="findComRecord">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>
		<!--列表-->
		<template>
			<el-table :data="recodes" highlight-current-row v-loading="loading" border max-height="620" style="width: 100%;">

				<el-table-column type="index" width="80" label="编号">
				</el-table-column>
				<el-table-column prop="chargeMoney" label="佣金金额(单位元)"   >
				</el-table-column>
				<!--<el-table-column prop="uporder.upphonenum" label="佣金号码"   >-->
				<!--</el-table-column>-->
				<el-table-column prop="chargeType" label="佣金类型"  :formatter="formatChargeType" >
				</el-table-column>
				<el-table-column prop="chargeTime" label="创建时间"   >
				</el-table-column>
				<el-table-column prop="remark" label="佣金备注"   >
				</el-table-column>
			</el-table>
		</template>
		<el-pagination
				@current-change="handleCurrentChange"
				@size-change="handleSizeChange"
				layout="total,sizes,prev, pager, next"
				:total="total">
		</el-pagination>

	</section>

</template>
<script>
	import {findComRecord} from '../../api/api';
	//import NProgress from 'nprogress'
    import moment from 'moment';
	export default {
		data() {
			return {
				filters: {
                    startTime:new Date(),
                    endTime:new Date(),
				},
                isShowSupper:JSON.parse(sessionStorage.getItem("user")).usertype === 2 ? true : false,
				start:0,
				pageSize:10,
                total:0,
				loading: false,
				recodes: [],
			}
		},
		methods: {
            formatChargeType:function (row, column) {
                return row.chargeType === 1 ? '增加' : row.chargeType === 2 ? '提取' : "其他";
            },
			//获取用户列表
            findComRecord: function () {
				let para = {
				    start:this.start,
                    pageSize:this.pageSize,
                    startTime:this.filters.startTime == "" ? "" : moment(this.filters.startTime,"YYYY-MM-DD HH:mm:ss").format('YYYY-MM-DD'),
                    endTime:this.filters.endTime == "" ? "" : moment(this.filters.endTime,"YYYY-MM-DD HH:mm:ss").format('YYYY-MM-DD'),
				};
				this.loading = true;
                findComRecord(para).then(datas => {
                    this.loading = false;
                    //NProgress.done();
                    let { message, code, data } = datas;
                    if (code !== "0") {
                        this.$message({
                            message: message,
                            type: 'error'
                        });
                    } else {
                        this.recodes = data.result;
                        this.total = data.totalCount;
                    }
                }).catch(e =>{

				});
			},handleCurrentChange:function(val){
                this.start = val - 1;
                this.findComRecord();
			},
            handleSizeChange:function(val){
			    this.pageSize = val;
			    this.findComRecord();
			}
		},

		mounted() {
			this.findComRecord();
		}
	};

</script>

<style scoped>

</style>
